#pragma once
#include "Point3D.h"
#include "Segment.h"
#include "Plane.h"

#include <sstream>

class Triangle
  {
  public:
    Triangle();
    Triangle(const Point3D& i_a,const Point3D& i_b, const Point3D& i_c);
    ~Triangle(void);
    Segment GetSide(int i_index) const;
    Point3D GetPoint(int i_index) const;
    Point3D GetBarycentric(const Point3D& i_point, double i_eps) const;
    bool IsInside(const Point3D& i_point, double i_eps) const;
    Point3D GetIntersectionPoint(const Triangle& i_other, double i_eps) const;
    Point3D GetIntersectionPoint(const Segment& i_segment, double i_eps) const;
    bool IsIntersect(const Triangle& i_other, double i_eps) const;
    double S() const;
    void SetRandom(int i_max_value);

    friend std::ostream& operator << (std::ostream& o_stream, const Triangle& i_tr);

  private:
    Point3D m_points[3];
    Plane m_plane;
  };

